package com.yf.service.impl;

import com.yf.domain.TsUser;
import com.yf.mapper.TsUserMapper;
import com.yf.service.TsUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.time.Duration;
import java.time.LocalDateTime;

@Service
@Slf4j
public class UserServiceAnother {
    @Resource
    private TsUserMapper tsUserMapper;
    @Transactional
    public void saveUser(TsUser user) {
        try {
            LocalDateTime beginTime = LocalDateTime.now();
            tsUserMapper.insert(user);
            Long opetime = Duration.between(beginTime, LocalDateTime.now()).toMillis();
            log.info("方法耗时 {} 毫秒",opetime);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }
}
